<?php
class CategoryModel extends Model{
    public function find($sign,$field = ''){
        $where = [];
        if(is_numeric($sign)){
            $where['id'] =  $sign;
        }else{
            $where['name'] = $sign;
        }
        return $this->field($field)->where($where)->one();
    }
    public function get_tree($id = 0, $field = ''){
        if($id != 0){
            $data = $this->find($id);
            $id = $data['id'];
        }
        $data = $this->select();
        // var_dump($data);
        $tree = Datum::entree($data,'id',$fid = 'fid',$sun = '_',$id);
        // var_dump($tree);
        return $tree;
    }
}